<template>
  <!-- <div :class="className" :style="{height:height,width:width}" /> -->
  <div>
    <el-row>
      <el-col :span="8" v-for="item in list" v-bind:key="item.name">
        <div style="padding:15px 10px;background: #f3f6ff;margin: 5px;color: #333333;">
          <div style="font-size:30px;font-weight:600">
            {{item.value}}
          </div>
          <div style="padding: 10px 0px;">
            <span>{{item.name}}</span>
            <span><svg-icon icon-class="04" style="font-size: 30px;margin-left: 20px;" /></span>
          </div>
        </div>        
      </el-col>
    </el-row>

  </div>
</template>

<script>
import echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'
import { getOrderStatusData} from "@/api/index";
const animationDuration = 3000

export default {
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: 'chart'
    },
    width: {
      type: String,
      default: '100%'
    },
    height: {
      type: String,
      default: '250px'
    }
  },
  data() {
    return {
      chart: null,
      list: []
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart()
    })
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    initChart() {
      // this.chart = echarts.init(this.$el, 'macarons')
      getOrderStatusData().then(res => {
        this.list = res.data;
        // this.setOptions(res.data);
      });
    },
    setOptions(list) {
      this.chart.setOption({
        tooltip: {
          trigger: 'item',
          formatter: "<br/>{b} : {c}"
        },
        
        legend: {
          right: '10',
          orient: 'vertical',
          data: list.map(a=>a.name)
        },
        series: [{
            name:'漏斗图',
            type:'funnel',
            left: '10%',
            top: 0,
            //x2: 80,
            bottom: 20,
            width: '80%',
            // height: {totalHeight} - y - y2,
            min: 0,
            max: 100,
            minSize: '0%',
            maxSize: '100%',
            sort: 'descending',
            gap: 2,
            label: {
                show: true,
                position: 'inside'
            },
            labelLine: {
                length: 10,
                lineStyle: {
                    width: 1,
                    type: 'solid'
                }
            },
            itemStyle: {
                borderColor: '#fff',
                borderWidth: 1
            },
            emphasis: {
                label: {
                    fontSize: 20
                }
            },
            data: list
        }]
      })
    }
  }
}
</script>
